import java.util.*;
public class task3 {

	public static void main(String[] args) {

		int size , d=0, i;

		Scanner sc= new Scanner(System.in);

		do{
		System.out.print("Enter the array size: ");
		size = sc.nextInt();

		if(size<1)
		System.out.println("Error: invalid input");
		}while(size<1);

		int[] a = new int[size];
		
		for(i=0 ; i<a.length ; i++)
		{
			a[i]=(int)(Math.random()*30) + 1;
			System.out.printf(" %d",a[i]);
		}
		
		System.out.print("Enter the value to search for: ");
		int target = sc.nextInt();
		
		for(i=0 ; i<a.length ; i++)
		{
			if(a[i]==target)
			{
				d = 1;
				break;
			}
		}
		
		if(d==1)
			System.out.printf("%n%nThe value %d is present in th array,its first index is %d",target,i);
		else
			System.out.printf("%n%nThe value %d is not present in th array.");
		
		sc.close();
	}

}
